package com.jobinn.web.action.ajax;


import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.jobinn.DAO.WidgetDAO;
import com.jobinn.JDOBean.Widget;
import com.jobinn.service.UserService;

public class MaxContentAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(
				this.getServlet().getServletContext()); 
		WidgetDAO widgetDAO = (WidgetDAO)ctx.getBean("widgetDAO");
		
		response.setContentType("text/html");
		request.setCharacterEncoding("GB2312"); 
		response.setCharacterEncoding("GB2312");
		String item = request.getParameter("item");
		String foward = "";
		if("user".equals(item)){
			foward = "user";
		}else if("cv".equals(item)){
				foward = "cv";
		}else if("wel".equals(item)){
			foward = "wel";
		}else if("job".equals(item)){
			foward = "job";
		}else if("analysis1".equals(item)){
			foward = "analysis1";
		}else if("analysis2".equals(item)){
			foward = "analysis2";
		}else if("widgets".equals(item)){
			List<Widget> widgets = widgetDAO.getAllWidgets();
			request.setAttribute("widgets", widgets);
			foward = "widgets"; 
		}else if("jobinnSpider".equals(item)){
			foward = "jobinnSpider";
		}else if("addJob".equals(item)){
			foward = "addJob";
		}else if("commender".equals(item)){
			foward = "commender";
		}
		return mapping.findForward(foward);
	}
	
}
